<?php include (dirname(__FILE__)."/../include/header.php"); ?>
<?php if(!isset($_SESSION['_shop'])){header("location:../user_login.php");}?>
<?php 
	$sql=mysql_query("select * from zy_shop where shop_id='".$_SESSION['_shop']['shop_id']."'");
	$shop=mysql_fetch_array($sql);
?>
 <div class="container">
    <ul class="breadcrumb">
      <li> 店铺名称 <span class="divider">/</span> </li>
      <li><a href="">修改密码</a></li>
    </ul>
    <div class="row">
      <div class="span12 wash-paper user-center profile">
        <div class="row">
          <div class="span3">
            <?php include (dirname(__FILE__)."/../include/shop/left.php"); ?>
          <div class="span9">
            <div class="main-content">
              <div class="content-header">
                <h3> 订单查询统计 </h3>
              </div>
              <div class="content-inner">
                <div class="order-list">
                  <div class="order-block">
                    <div class="order-header">
                      <div class="line-one">
                        <div class="status-wrapper">
                          <div class="status orange">所有订单</div>
                        </div>
                      </div>
                      <div class="line-two">
                        <table class="table table-condensed">
                          <tbody>
                            <tr>
                              <td class="col1"><span class="item-name">开始日期:</span><input id="d11" type="text" name="start_date" value="<?php if(isset($_GET['start_date'])){ echo  $_GET['start_date'];} else{ echo date("Y-m-d",strtotime("-1 month",time()));}?>" onclick="WdatePicker()" style="width:100px; text-align:center;"></td>
                              <td class="col2"><span class="item-name">结束日期:</span><input id="d12" type="text" name="end_date" value="<?php if(isset($_GET['end_date'])){ echo $_GET['end_date'];} else {echo date("Y-m-d",time());}?>" onclick="WdatePicker()" style="width:100px; text-align:center;"></td>
							  <?php 
							  if(isset($_REQUEST['start_date'])){
							$start_date=$_REQUEST['start_date']. " 00:00:00";}else{
  								$start_date=date("Y-m-d 00:00:00",strtotime("-1 month",time()));
  							}
  							if(isset($_REQUEST['start_date'])){
							$end_date=$_REQUEST['end_date']." 23:59:59";}else{
									$end_date=date("Y-m-d 23:59:59",time());
								}
							  //echo $start_date;
							  //echo $end_date;
							  ?>
                              <td class="col3"><span class="item-name"></span><input  type="button" class="btn btn-yellow" id="" style="float:right;" value="查询"   onclick="javascript:queryTotal();"/></td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </div>
					
                    <div class="order-table-wrapper">
                      <table class="order-table table table-striped">
					 
					  
                        <thead>
                          <tr>
                            <th class="col-name">订单号</th>
                            <th class="col-date">订单日期</th>
                            <th class="col-sub-total">金额</th>
                          </tr>
                        </thead>
                        <tbody>
						 <?php 
						 $sql="select * from zy_order where ";
						 $where="order_time between '$start_date'  and '$end_date'";
						
						$sql=$sql.$where."AND shop_id='".$_SESSION['_shop']['shop_id']."'";
						 // $sql= "select * from zy_order where order_time between '2012-07-01' and '2012-09-01'";
					  	// echo $sql;
						$result = mysql_query($sql);
						$total = 0;
						if(isset($_SESSION['_shop'])){
					  while($zy_order=mysql_fetch_array($result)){
					  
						if($zy_order['totalPrice']>0)
						{
						  $total+=$zy_order['totalPrice'];
						}
						//echo $zy_order['totalPrice'];
						//echo "<br>";
						// echo $total;
						//print_r($zy_order);
					 ?>
                         
                          <tr 4895420>
                            <td class="col-name"><span>
                            <a href="javascript:openwin('<?php echo $zy_order['ord_id'];?>');"  ><?php echo $zy_order['ord_id']; ?></a></span></td>
                            <td class="col-date"><span><?php echo $zy_order['order_time'];?></span></td>
                            <td class="col-sub-total"><?php echo $zy_order['totalPrice']; ?></td>
                          </tr>
						   <?php }?>
						   <?php }?>
                        </tbody>
						
                      </table>
                      <table class="order-table total-table table table-striped">
					  
                        <tfoot>
                          <tr>
                            <td class="col-name">合计</td>
							<th class="col-date"></td>
                            <td class="col-sub-total"><?php echo $total;?></td>
                          </tr>
                        </tfoot>
                      </table>
                    </div>
                  </div>
				 
              <div id="modal-shuiqunawaimai" class="modal hide fade" style="display: none; ">
                <div class="modal-header"> <a href="#" class="close">×</a>
                  <h3>谁去拿外卖</h3>
                </div>
                <div class="modal-body">
                  <div class="" id="shuiqunawaimai">
                    <div id="title">谁去拿外卖</div>
                    <div id="triggerContainer" > <a href="#"  id="trigger" ></a> </div>
                    <div id="resultContainer">
                      <p id="description"><span>随机到最小数字的人去拿外卖</span></p>
                      <div id="heightfixer"></div>
                      <ul id="result">
                      </ul>
                      <div id="lastResult">↓ Start </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <a id="back-to-top" href="javascript:void(0);">
    <div class="backtotop"></div>
    </a> </div>
<?php include (dirname(__FILE__)."/../include/footer.php"); ?>
<script type="text/javascript">
function queryTotal(){
	var x=document.getElementsByName("start_date")[0];
	var y=document.getElementsByName("end_date")[0];
    //alert(x.value);
    //alert(y.value);
	location.href="order_list.php?start_date="+x.value+"&end_date="+y.value;
}
function openwin(order_id){	
	if(navigator.appName=="Microsoft Internet Explorer"){	
		window.showModalDialog('<?php echo SITE_ROOT;?>/shop/item_show.php?id='+order_id,'','dialogWidth=900px;dialogHeight=600px');	
	}
	else if(navigator.appName=="Netscape"){		
		window.open('<?php echo SITE_ROOT;?>/shop/item_show.php?id='+order_id,'','width=900,height=600,modal=yes,location=no,status=no,toolbar=no,resizble=yes'); 
	}	
}
</script>
